<?php $this->load->view('common/head');?>
<?php $this->load->view('common/navbar');?>
<form class="form-inline" method="GET" name="report" id="report">
<input type="hidden" name="c" id="c" value="Report">
<input type="hidden" name="m" id="m" value="index">
<!-- Table -->
  <table class="table table-condensed">
    <tbody>
      <tr>
        <td class="bg-primary col-md-2">所属区域：</td>
        <td>
        	<div class="form-group">
			    <label for="area">地区:</label>
			    <select class="form-control" id="area" name="area">
				  <option value="">请选择地区</option>
				</select>
			  </div>
			  <div class="form-group">
			    <label for="spsarea">小区:</label>
			    <select class="form-control" id="spsarea" name="spsarea">
				  <option value="">请选择大区</option>
				</select>
			  </div>
			  <div class="form-group">
			    <label for="province">省份:</label>
			    <select class="form-control" id="province" name="province">
				  <option value="">请选择省份</option>
				</select>
			  </div>
			  <div class="form-group">
			    <label for="city">城市:</label>
			    <select class="form-control" id="city" name="city">
				  <option value="">请选择城市</option>
				</select>
			  </div>
			  <div class="form-group">
			    <label for="storeId">专营店:</label>
			    <select class="form-control" id="storeId" name="storeId">
				  <option value="">请选择专营店</option>
				</select>
			  </div>
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-2">所属年月：</td>
        <td>
        	  <div class="form-group">
			    <label for="year">所属年份：</label>
			    <select class="form-control" required id="year" name="year">
			      <option value="">请选择</option>
				</select>
			  </div>
			  <div class="form-group">
			    <label for="timeUnit">所属双月：</label>
			    <select class="form-control" required id="timeUnit" name="timeUnit">
			      <option value="">请选择</option>
				</select>
			  </div>
        </td>
      </tr>
      <!-- <tr>
        <td class="bg-primary col-md-2">是否为补报：</td>
        <td>
        	<div class="form-group">
      			    <label class="radio-inline">
      				  <input type="radio" required name="isBubao" id="isBubao1" <?=$isBubao==0 ? 'checked' : ''?> value="0"> 否
      				</label>
      				<label class="radio-inline">
      				  <input type="radio" required name="isBubao" id="isBubao2" <?=$isBubao==1 ? 'checked' : ''?> value="1"> 是
      				</label>
      			</div>
        </td>
      </tr> -->
      <tr>
        <td class="bg-primary col-md-2">基金类型：</td>
        <td>
        	<select class="form-control" required id="fundType" name="fundType">
		      <option value="">请选择</option>
		      <?php foreach ($this->fundList as $k => $v) {?>
			    <option value="<?=$k?>" <?=$fundType==$k ? 'selected="selected"' : ''?>><?=$v?></option>
		      <?php } ?>
			</select>
        </td>
      </tr>
      <tr>
        <td class="bg-primary col-md-2">报表类型：</td>
        <td>
        	<div class="form-group">
			    <select class="form-control" required id="reportType" name="reportType">
			      <option value="">请选择</option>
				</select>
			  </div>
        </td>
      </tr>
      <tr>
      	<td colspan="2" class="text-center">
      		<button type="submit" name="submit" id="submit" value="export" class="btn btn-default  btn-primary">导出</button>
      	</td>
      </tr>
    </tbody>
  </table>
</form>
<script type="text/javascript">
	$(function(){
		$('form[name="report"]').find("input,select,textarea").not("[type=submit]").jqBootstrapValidation();
		loadYearList('year',<?=$year ? $year : 0?>);
	    loadTimeUnitList('timeUnit',<?=$year ? $year : 0?>,<?=$timeUnit ? $timeUnit : 0?>);
		loadPlaceList('area', 'area', '', '<?=$area?>');
		loadPlaceList('spsarea', 'spsarea', '<?=$area?>', '<?=$spsarea?>');
		loadPlaceList('province', 'province', '<?=$spsarea?>', '<?=$province?>');
		loadPlaceList('city', 'city', '<?=$province?>', '<?=$city?>');
		loadPlaceList('storeId', 'store', '<?=$city?>', '<?=$storeId?>');
		loadReportList(<?=$fundType ? $fundType : 0?>, <?=$reportType ? $reportType : 0?>);
	});
    $("#year").change(function(){
      loadTimeUnitList('timeUnit',this.value);
    });
	$('#area').change(function(){
		loadPlaceList('spsarea', 'spsarea', this.value, '');
		loadPlaceList('province', 'province', '', '');
		loadPlaceList('city', 'city', '', '');
		loadPlaceList('storeId', 'store', '', '');
	});
	$('#spsarea').change(function(){
		loadPlaceList('province', 'province', this.value, '');
		loadPlaceList('city', 'city', '', '');
		loadPlaceList('storeId', 'store', '', '');
	});
	$('#province').change(function(){
		loadPlaceList('city', 'city', this.value, '');
		loadPlaceList('storeId', 'store', '', '');
	});
	$('#city').change(function(){
		loadPlaceList('storeId', 'store', this.value, '');
	});
	$("#fundType").change(function(){
		fundTypeChange(this.value);
	});
	//基金类型改变
    function fundTypeChange(fundType, sec){
    	if(fundType == 4 || fundType ==5){
	    	$('input:radio[name=isBubao]')[0].checked = true;
    		$('input:radio[name=isBubao]').attr('disabled',true);
    	}else{
    		$('input:radio[name=isBubao]').attr('disabled',false);
    	}
    	loadReportList(fundType, sec);
    }
function loadReportList(fundType, sec){
	$.post(
		"index.php?c=Report&m=loadReportList",
		{
			fundType:fundType,
		},
		function(data){
			var html = '';
			$.each(data,function(i, n){
				if (n.key==sec) {
					html += '<option value="'+n.key+'" selected="selected">'+n.value+'</option>'+"\r\n";
				}else{
					html += '<option value="'+n.key+'">'+n.value+'</option>'+"\r\n";
				}
			});
			if (html) {
				$("#reportType").html(html);
			}
		},'json'
	);
}
</script>
<?php $this->load->view('common/foot');?>